package com.example.demo.spring.reflect;


import java.lang.reflect.Method;

/**
 * @program: demo
 * @description:
 * @author: yby
 * @create: 2020-06-28 15:39
 **/
public class TestReflect {
    public static void main(String[] args) throws Exception {
        Class<?> clz = Class.forName("com.example.demo.spring.reflect.Book");
        Object o = clz.newInstance();
        Method m = clz.getDeclaredMethod("say", String[].class);
        m.invoke(o, new String[]{"我是方法1", "faf"});

        String aaa[] = new String[]{"aaa","fff","111"};

        A a = new A();
        //a.hello(new String[]{"fafaf"});
    }
    static class A{
        public void hello(String...args) {
            for (String arg : args) {
                System.out.println(arg);
            }
        }

        public void speak(String[] args) {
            for (String arg : args) {
                System.out.println(arg);
            }
        }
    }

}
